<%-- 
    Document   : checkout
    Created on : 23 Jun, 2011, 11:59:13 AM
    Author     : mpower
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.List,shopping.Item"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>

       <%
            List<Item> cart=(List<Item>)session.getAttribute("cart");
            if((!(cart==null))&&(!(cart.isEmpty()))) {
       %>
       <p align="center"><b>Items in Cart</b></p>
           <table border="1" align="center">
               <tr>
                   <th>Item Code</th>
                   <th>Item Name</th>
                   <th>Qty.</th>
                   <th>Price(Rs.)</th>
                   <th>Amount(Rs.)</th>
               </tr>
           <%
           double total=0.0;
           for(Item item:cart) {
               double amount=item.getPrice()*item.getQty();
               total+=amount;
               %>
               <tr>
                   <td><%=item.getItemCode()%></td>
                   <td><%=item.getItemName()%></td>
                   <td align="right"><%=item.getQty()%></td>
                   <td align="right"><%=item.getPrice()%></td>
                   <td align="right"><%=amount%></td>
               </tr>
                   <%
                   }
                   %>
                   <tr>
                       <td colspan="5" align="right">Total:Rs.<%=total%></td>
                   </tr>
                   </table>
                       <%
                        session.invalidate();//signs out the user.
                       }
                       %>
                       <br><a href="<%=request.getContextPath()%>/home.jsp">Shop more...</a>
    </body>
</html>
